package polymorphic.exer1;

/**
 * Created with IntelliJ IDEA.
 * ClassName: GemoetricTest
 * Package: polymorphic.exer1
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-22
 * Time: 21:29
 */

public class GemoetricTest {


    public static void main(String[] args) {
        GemoetricTest test = new GemoetricTest();

        Circle c1 = new Circle("red", 1.0, 2.3);
        Circle c2 = new Circle("red", 1.0, 3.3);
        //虚拟方法调用 动态绑定
        test.displayGeometricObject(c1);
        test.displayGeometricObject(c2);

        System.out.println(test.equalsArea(c1,c2));

    }

    //比较几何图形的面积是否相等
    public boolean equalsArea(GeometricObject g1, GeometricObject g2) {
        return g1.findArea() == g2.findArea();
    }

    //显示对象的面积
    public void displayGeometricObject(GeometricObject g) {
        System.out.println("几何图形的面积为: " + g.findArea());
    }

}
